package com.henry.sprite;

import java.awt.Graphics;

public abstract class Mover {
    protected int x;
    protected int y;
    protected int xDirection;
    protected int yDirection;
    protected Sprite sprite;

    /** Create a mover that positions sprite at (startX, startY). */
    public Mover(int startX, int startY, int directionX, int directionY, Sprite s) {
        this.x = startX;
        this.y = startY;
        this.xDirection = directionX;
        this.yDirection = directionY;
        this.sprite = s;
    }

    /** Starts moving the object in the direction of (dx, dy). */
    public void setMovementVector(int dx, int dy) {
        xDirection = dx;
        yDirection = dy;
    }

    public abstract void move();

    /** Draws the sprite at its current position on to surface. */
    public void draw(Graphics surface) {
        sprite.draw(surface, x, y);
        // Move the object each time we draw it
        this.move();
    }
}
